package net.wanho.service.impl;

import lombok.RequiredArgsConstructor;
import net.wanho.dao.UserDao;
import net.wanho.entity.User;
import net.wanho.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * Author：汤小洋
 * Date：2025-06-26 11:26
 * Description：<描述>
 */
@Service("userService")
@RequiredArgsConstructor
@Lazy
@Primary // 优先使用这个bean
@Scope("prototype") // 多例
public class UserServiceImpl implements UserService {

    private final UserDao userDao;

    @Override
    public void register(User user) {

        userDao.insert(user);
    }

    @Override
    public User login(String username, String password) {
        // int i = 5/0;
        return new User(1, "", password, LocalDateTime.now());
    }
}
